package mop.controller;

import java.sql.Timestamp;
import java.util.Date;

import mop.model.World;
import mop.model.task.Task;

/**
 * ChangeClockController
 * 
 * CUSTOM USE CASE
 * Use case controller for changing the date
 * 
 * @author	MOP Team 7
 */
public class ChangeClockController extends UseCaseController
{

	/**
	 * @see UseCaseController#UseCaseController(World)
	 */
	public ChangeClockController(World world)
	{
		super(world);
	}
	
	/**
	 * Get the virtual time
	 * @return	time
	 * 	|@see getWorld()#getTime()
	 */
	public Date getVirtualTime()
	{
		return World.getTime();
	}

	
	/**
	 * setVirtualTime - changes the virtual time
	 * 
	 * @param time - date & time (timestamp) for the virtual time
	 * @effect	Change the virtual time
	 * 	|@see System#setVirtualTime(int)
	 */
	public void setVirtualTime(Timestamp time)
	{
		World.setVirtualTime(time);
		for(Task t : getWorld().getAllTasks()){
			t.getStatus().refreshStatus();
		}
	}	
	
	/***************************************************************************
	 * 								Visit
	 ***************************************************************************/
	
	/**
	 * Make a CallBack to the visitor
	 * @param v the visitor
	 */
	public void visit(ControllerVisitor v)
	{
		v.action(this);
	}
	
}